package structure_结构性.adapter_pattern_适配器模式;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: hihi
 * @Date: 2020/07/03/18:26
 * @Description:
 */
public class MediaPlayAdapter implements MediaPlayer {

	AdvancedMediaPlayer advancedMediaPlayer;

	public MediaPlayAdapter(String mediaType) {
		if (mediaType.equalsIgnoreCase("mp4")) {
			advancedMediaPlayer = new MP4Player();
		}
		if (mediaType.equalsIgnoreCase("vlc")) {
			advancedMediaPlayer = new VLCPlayer();
		}
	}

	@Override public void play(String mediaType, String fileName) {
		if (mediaType.equalsIgnoreCase("mp4")) {
			advancedMediaPlayer.playMP4(fileName);
		}
		if (mediaType.equalsIgnoreCase("vlc")) {
			advancedMediaPlayer.playVLC(fileName);
		}
	}
}
